/**
 * Copyright 2010 Marcus Calverley <marcus@calverley.dk>
 *
 * This file is part of I'm Busy.
 *
 * I'm Busy is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * I'm Busy is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with I'm Busy.  If not, see <http://www.gnu.org/licenses/>.
 */
package dk.lmz.android.busy;

import android.content.Context;
import android.database.ContentObserver;
import android.os.Handler;

/**
 * Monitors the list of calendars for changes and updates the preference to remove deleted calendars.
 * 
 * @author Marcus Calverley <marcus@calverley.dk>
 */
public class CalendarListObserver extends ContentObserver
{
	private final Context context;

	public CalendarListObserver(Handler handler, Context context)
	{
		super(handler);
		this.context = context;
	}

	@Override
	public void onChange(boolean selfChange)
	{
		BusyService.log("Calendar list updated, applying changes");
		BusyService.setSelectedCalendars(context, BusyService.getSelectedCalendars(context)); // TODO possible race condition?
	}
}
